// 1. 启动一个后端服务
const express = require("express");
const Exapp = express();
const cors = require("cors");
const bodyParser = require("body-parser");
const https = require('https')
const fs = require('fs')
// 1.2 配置post请求
Exapp.use(bodyParser.urlencoded({ extended: true }));
Exapp.use(bodyParser.json());
// 1.3 配置跨域设置
Exapp.use(cors());



Exapp.all('*', (req, res, next) => {
    next()
})




// 路由
Exapp.use('/class', require('./routes/class'))
Exapp.use('/foodfriends', require('./routes/foodfriends'))
Exapp.use('/home', require('./routes/home'))
Exapp.use('/my', require('./routes/my'))


// 访问静态资源目录
Exapp.use(express.static(__dirname))


// 引入 ssl 证书
const httpsOption = {
    key: fs.readFileSync("../https/5026783_webpti.cn.key"),
    cert: fs.readFileSync("../https/5026783_webpti.cn.pem")
}
// 1.4 开启后端服务端口
// Exapp.listen(5656, () => console.log("https://localhost:5656"));
https.createServer(httpsOption, Exapp).listen(5656, () => { console.log("https://localhost:5656") })

